package org.javastudy.tang.rmi;

import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;

import java.lang.ref.Reference;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * <p><em>Created on 2021/12/13 9:54 上午</em></p>
 *
 * @author fuzhongtang
 * @since 1.0.1
 */
public class RMIServer {
    public static void main(String[] args) {
        try
        {
            int iPort = 8088;
            LocateRegistry.createRegistry(iPort);
            Naming.bind("rmi://localhost:"+iPort+"/userService",getUserService());
            System.out.println("listen RMI ...port="+iPort);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    private  static UserService getUserService() throws RemoteException {
        UserService userService = new UserServiceImpl();
        return userService;
    }
}
